package com.lj.tools;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;

/**
 * 这个类主要用来读取maven下的资源文件
 * 
 * @author Administrator
 * 
 */
public class MavenResourcePath {
	public static String getPath(String resourcePath) {

		ClassLoader classLoader = MavenResourcePath.class.getClassLoader();
		String path = classLoader.getResource(resourcePath).getPath();
		try {
			path = java.net.URLDecoder.decode(path, "utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		File file = new File(path);
		path = file.getAbsolutePath().toString();
		return path;

	}

	public static void main(String[] args) throws URISyntaxException {
		String path = getPath("spring/applicationContext.xml");
		System.out.println("path:"+path);
	}

}
